﻿using System.Collections.Generic;
using DBCodeBuilder.Core.Enum;
using DBCodeBuilder.Core.Interfaces;

namespace DBCodeBuilder.Core.Classes
{
    public static class ModelObjectDispatcher
    {
        public static void Dispatch(List<IDbObjectModel> toDispatch, out List<IDbObjectModel> tables,
            out List<IDbObjectModel> views, out List<IDbObjectModel> procs)
        {
            tables = new List<IDbObjectModel>();
            procs = new List<IDbObjectModel>();
            views = new List<IDbObjectModel>();

            foreach (var model in toDispatch)
            {
                switch (model.ObjectType)
                {
                    case DbObjectType.Procedure:
                        procs.Add(model);
                        break;
                    case DbObjectType.Table:
                        tables.Add(model);
                        break;
                    case DbObjectType.View:
                        views.Add(model);
                        break;
                }
            }
        }
    }
}